The Document Object Model and JavaScript > How JavaScript works in extensions |
![]() ![]() ![]() |
How JavaScript works in extensions
When Dreamweaver processes extensions, it compiles everything between SCRIPT
tags and executes any code within SCRIPT
tags that is not part of a function declaration (for example, initialization of global variables). It also reads in, compiles, and executes scripts in external JavaScript files specified in the SRC
attributes of SCRIPT
tags.
Note: If any JavaScript code in your extension files contains the string '</SCRIPT>'
, the JavaScript interpreter reads this as an actual closing SCRIPT
tag and reports an unterminated string literal error. To avoid this problem, break the string into pieces and concatenate them, like this: '<' + '/SCRIPT>'
.
In command and behavior action files, Dreamweaver executes code in the onLoad
event handler (if one appears in the BODY
tag) when the user chooses the command or action from a menu. In object files, Dreamweaver executes code in the onLoad
event handler on the BODY
tag if the body of the document contains a form. Dreamweaver ignores the onLoad
handler on the BODY
tag in data translator, Property inspector, and floating panel files. In all extensions, Dreamweaver executes code in other event handlers (for example, onBlur="alert('This is a required field.')"
) when the user interacts with the form fields to which they are attached.
Links (a
tags, including those with JavaScript URLs such as <a href="javascript:alert('hi')">
), are not supported, nor is the document.write()
statement. Plug-ins (set to play
at all times) are supported in the BODY
of extensions, but Java applets and ActiveX controls are not.
![]() ![]() ![]() |